<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map"%>
<%@page import="com.cqeec.myblog.model.DataDictionary"%>
<%@page import="java.util.List"%>
<%@page import="com.cqeec.myblog.model.Article"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="include/resources.jsp"%>
<title>我的博客</title>
</head>
<body>
	<div class="container-fluid">
		<%@include file="include/header.jsp"%>
		<div class="row">
			<div class="col-sm-8">
				<%-- 创建博文 --%>

				<%
					if (blogger != null) {
				%>
				<br />
				<button class="btn btn-primary">创建文章</button>
				<br />
				<%
					}
				%>

				<%-- 博文列表 --%>
				<%-- 输出10篇文章 --%>
				<%
					Object obj = request.getAttribute("list");
					if (obj != null) {
						List<Article> list = (List<Article>) obj;
						for (Article a : list) {
				%>
				<br />
				<div class="card">
					<div class="card-header">
						<a href="${contentPath}/article/view.html?id=<%=a.getId() %>"
							target="_blank"><h5 class="card-title"><%=a.getTitle()%></h5></a>
					</div>
					<div class="card-body"
						style="height: 300px; overflow: hidden; text-overflow: ellipsis;">
						<p class="card-text"><%=a.getContent()%></p>
					</div>
					<div class="card-footer">
						<span class="align-middle" style="color: #ccc;">发布时间：<%=a.getCreationTime()%></span>
						<%
							if (blogger != null) {
						%>
						<a href="#" target="_blank" class="btn btn-danger float-right"
							style="margin-left: 10px;">删除文章</a> <a href="#" target="_blank"
							class="btn btn-info float-right" style="margin-left: 10px;">修改文章</a>
						<%
							}
						%>
						<a href="${contentPath}/article/view.html?id=<%=a.getId() %>"
							target="_blank" class="btn btn-primary float-right">阅读全文</a>
					</div>
				</div>
				<%
					}
					}
				%>
			</div>
			<div class="col-sm-4">
				<%-- 博文分类标签 --%>
				<br />
				<h5>文章分类标签</h5>
				<ul class="list-group">
					<%
						Map<String, Integer> atMap = (Map<String, Integer>) request.getAttribute("atMap");
						Iterator<String> iterator = atMap.keySet().iterator();
						String key;
						int total;
						while (iterator.hasNext()) {
							key = iterator.next();
							total = atMap.get(key);
					%>
					<li
						class="list-group-item d-flex justify-content-between align-items-center">
						<%=key%> <span class="badge badge-primary badge-pill"><%=total%></span>
					</li>
					<%
						}
					%>
				</ul>
			</div>
		</div>
		<div class="row" style="margin: 20px 0px;">
			<div class="col">
				<p class="text-center">&copy;2018&nbsp;&nbsp;&nbsp;重庆信息技术职业学院&nbsp;&nbsp;&nbsp;软件学院&nbsp;&nbsp;&nbsp;软件开发教研室&nbsp;&nbsp;&nbsp;唐礼飞</p>
			</div>
		</div>
	</div>
</body>
</html>